﻿using Microsoft.Extensions.Configuration;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Util
{
    public class SqlSugarClientFactory : ISqlSugarClientFactory
    {
        private readonly IConfiguration _configuration;

        public SqlSugarClientFactory(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        public ISqlSugarClient Create()
        {
            return new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = AppSettingHelper.app(new string[] { "AppSettings", "ConnectionStrings" }),//数据库链接字符串
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute // 从实体特性中读取主键自增列信息
            });
        }
    }
}
